package com.briup.day24;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;

public class Test_RandomAccessFile {
    public static void main(String[] args) throws Exception {
        //创建随机访问流对象 对文件进行读写操作 和随机访问的操作
        RandomAccessFile f = new RandomAccessFile(new File("01-Basic/src/dir/a.txt"),"rw");
        int pos = 6;
        String content = "briup";
       f.seek(pos);
       f.write(content.getBytes());
       f.seek(0);
        int len;
        byte[] buf = new byte[8];
        while ((len = f.read(buf)) != -1) {
            System.out.println(new String(buf, 0, len));
        }
        f.close();
    }
}
